package main.java.exception;

public class TryCatchDemo {
    public static void main(String[] args) {
        System.out.println("程序开始了");
        try {
            String s = "abc";
            System.out.println(s.length());
            System.out.println(s.charAt(3));
            System.out.println("!!!!!!!!");
        }catch (NullPointerException | StringIndexOutOfBoundsException e){
            System.out.println("出现空指针或下标越界异常的统一处理方式");
        }catch (Exception e){
            System.out.println("出现未知异常,请提交report");
        }
        /* }catch (NullPointerException e){
            System.out.println("空指针异常");
        }catch (StringIndexOutOfBoundsException e){
            System.out.println("下标越界异常");
        }*/
        System.out.println("程序结束了");
    }
}
